Ext.require([
	'Ext.grid.*',
	'Ext.data.*',
	'Ext.util.*',
	'Ext.toolbar.Paging',
	'Ext.ModelManager',
    'Ext.tip.QuickTipManager'
]);

Ext.onReady(function() {
	
	Ext.QuickTips.init();
	
	Ext.define('ResourceModel', {
		extend: 'Ext.data.Model',
		fields: [
			{name: 'id', type: 'int'},
			{name: 'nodeId', type: 'int'},
			{name: 'menuName', type: 'string'},
			{name: 'icon', type: 'string'},
			{name: 'parantNodeID', type: 'int'},
			{name: 'actionPath', type: 'string'},
			{name: 'description', type: 'string'}
		],
		idProperty: 'id'
	});
	
	
	var store = Ext.create('Ext.data.Store', {
		pageSize: 20,
		model: 'ResourceModel',
		remoteSort: true,
		proxy: {
			type: 'ajax',
			url: '../basic/ResourcesAction/search.action',
			reader: {
				type : 'json',  
				root: 'invdata',
				totalProperty: 'total'
			},
			simpleSortMode: true
		},
		sorters: [{
            property: 'menuName',
            direction: 'DESC'
        }]
	});
	
	
	var grid = Ext.create('Ext.grid.Panel', {
		width: 700,
        height: 300,
        title: 'AAAAAAAAAAAA',
        store : store,
        loadMask: true,
        columns : [
        	{text : "id", dataIndex : "id",sortable: true},
        	{text : "nodeId", dataIndex : "nodeId",sortable: true},
        	{text : "menuName", dataIndex : "menuName",sortable: true}
       ],
       bbar: Ext.create('Ext.PagingToolbar', {
       		store : store,
       		displayInfo: true,
            displayMsg: 'Displaying topics {0} - {1} of {2}',
            emptyMsg: "No topics to display",
            items: [
            ]
       })
        
	});
	
	grid.addListener('itemdblclick', function(grid, rowindex, e) {
		alert(100);
	});
	
	grid.render(document.body);
	
	store.loadPage(1);
	
});
